﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;

namespace Dynamic_UI_Framework
{
    [Export(typeof(DesignerItemAdapter))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class DesignerItemAdapter : AdapterBase<IDesignerItem, DesignerItemControl>
    {
        protected override void Adapt(IDesignerItem codon, DesignerItemControl target)
        {
            codon.Target = target;

            DesignerItem di = codon as DesignerItem;
            di.CurrentItemChanged += (s, e) =>
            {
                target.Content = di.CurrentItem.Target;
            };
        }

        protected override IDesignerItem Create()
        {
            return new DesignerItem();
        }
    }
}
